package com.mooc.lib_find.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.google.android.material.button.MaterialButton
import com.mooc.lib_find.R
import com.mooc.lib_find.model.FindUserEntity
import com.mooc.lib_network.imgload.ImageLoad

class FindListAdapter : BaseQuickAdapter<FindUserEntity,BaseViewHolder>(R.layout.layout_tag_list_item) {

    var tag : String ?= null

    init {
        addChildClickViewIds(R.id.find_follow_tv)
    }

    override fun convert(holder: BaseViewHolder, item: FindUserEntity) {
        val headImg = holder.getView<ImageView>(R.id.find_head_icon)
        val find_title_tv = holder.getView<TextView>(R.id.find_title_tv)
        val find_desc_tv = holder.getView<TextView>(R.id.find_desc_tv)
        find_title_tv.setText(item.title)
        find_desc_tv.setText(item.intro)
        ImageLoad.loadMatch(item.icon!!,headImg)
        val find_follow_tv = holder.getView<MaterialButton>(R.id.find_follow_tv)
        if (item.hasFollow)
            find_follow_tv.visibility = View.GONE
        else
            find_follow_tv.visibility = View.VISIBLE

    }
}